#include<ros/ros.h>
#include<turtlesim/Pose.h>
#include<iomanip>
//订阅话题turtle1/pose， 获得海龟位置消息
void poseMessageRecevied(const turtlesim::Pose& msg){
	ROS_INFO_STREAM(std::setprecision(2) << std::fixed <<"position=("<<msg.x<<","<<msg.y<<")"<<"*direction="<<msg.theta);
}

int main(int argc,char** argv){
	ros::init(argc,argv,"subscribe_to_pose");
	ros::NodeHandle nh;

	//创建订阅者对象，（话题名称， 接受消息的队列大小，回调函数）
	ros::Subscriber sub = nh.subscribe("turtle1/pose", 1000, &poseMessageRecevied);
	//确保允许回调发生,ros::spinOnce()有略微不同
	ros::spin();
}
